package key.w8;

import key.w8.boot.annotation.EnableK8Reference;
import key.w8.boot.annotation.K8ReferenceService;
import key.w8.ref.TestService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * Hello world!
 *
 */
@SpringBootApplication
@ComponentScan(basePackages = {
        "key.w8.boot"
})
@EnableK8Reference
public class ConsumerServer
{
    @K8ReferenceService(version = "1.0",group = "default")
    TestService testService;

    public static void main( String[] args ) throws ExecutionException, InterruptedException {
        ConfigurableApplicationContext context = SpringApplication.run(ConsumerServer.class);
        ConsumerServer bean = context.getBean(ConsumerServer.class);
        Future<String> test =
                bean.testService.serviceString(UUID.randomUUID().toString());
        String result = test.get();
    }
}
